/**
 * @param {number[]} nums
 * @return {number}
 */
var findMiddleIndex = function (nums) {
  let right = 0, index = -1, left = 0
  for (const num of nums) {
    right += num
  }


  for (let i = 0; i < nums.length; i++) {
    if (left == right) {
      index = i
      break
    } else {
      temp += nums[i]
      right -= nums[i]
    }
  }
  return index
};